package com.notice.ui;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class Demo_ScrollableTabHost2 extends ScrollableTabActivity{
	private String id;

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        /*
         * set this activity as the tab bar delegate
         * so that onTabChanged is called when users tap on the bar
         */
        setDelegate(new SliderBarActivityDelegateImpl());
        
        /*
         * optional
         * set default off and on color shades of tab bar button
         * if not specified, opaque areas are shaded gray in off state, and yellow in on state 
         */
        setDefaultShade(RadioStateDrawable.SHADE_GRAY, RadioStateDrawable.SHADE_GREEN);
        
        for (int i=0; i<7; i++)
        {
        	Intent intent;
        	
        intent = new Intent(this, CourseListActivity.class);
        intent.putExtra(id, String.valueOf(i));
        	/*
        	 * This adds a title, and an image to the tab bar button
        	 * Image should be a PNG file with transparent background.
        	 * By default, opaque areas are shaded gray in off state, and yellow in on state 
        	 */
        String d = null;
        if(i==0)d="一";
        if(i==1)d="二";
        if(i==2)d="三";
        if(i==3)d="四";
        if(i==4)d="五";
        if(i==5)d="六";
        if(i==6)d="日";
        
        	this.addTab("周"+d, R.drawable.star, intent);

        }
        
        /*
         * commit is required to redraw the bar after add tabs are added
         * if you know of a better way, drop me your suggestion please.
         */
        commit();
    }
 
    private class SliderBarActivityDelegateImpl extends SliderBarActivityDelegate
    {
    	/*
    	 * Optional callback method
    	 * called when users tap on the tab bar button
    	 */
    	protected void onTabChanged(int tabIndex) 
    	{
    		Log.d("onTabChanged",""+tabIndex);
    	}
    }
}
